
var api = require('../../utils/api.js');
var app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        see:0,
        progressSteps: [
            { label: '1', text: '提交信息', active: true},
            { label: '2', text: '在线支付', active: true},
            { label: '3', text: '专人服务', active: false},
            { label: '4', text: '服务完成', active: false}
        ],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var id=options.id;
        console.log('-----------',id);
        var that=this;
        this.setData({
            id:id
        })
        this.getoderbyid();
    },

    getoderbyid(){
        var id=this.data.id;
        var that=this;
        api.post({
            url: 'order/getorderbyid',
            data: {id:id},
            success: data => {
                that.setData({
                    order:data.data.order,
                    progressSteps:data.data.array
                })
            }
        })
    },
    deleteorder(ret){
        var id=this.data.id;
        var that=this;
    

        wx.showModal({
          title: '删除订单？',
          content: '确认要删除订单',
          complete: (res) => {
    
            if (res.confirm) {
                api.post({
                    url: 'order/deletebyid',
                    data: {id:id},
                    success: data => {
                        wx.navigateBack();
                    }
                })
            }
          }
        })
    },

    payorder(ret){
        var id=this.data.id;
        var that=this;
        // 支付
        api.post({
            url: 'order/paybyid',
            data: {id:id},
            success: data => {
                console.log(data);
                wx.requestPayment({
                    timeStamp:data.data.timeStamp,
                    nonceStr: data.data.nonceStr,
                    package: data.data.package,
                    signType: 'MD5',
                    paySign: data.data.paySign,
                    success (res) {
                        that.getoderbyid();
                    }
                })
                }
            })
    },

    backmoney(ret){
        var id=this.data.id;
        var that=this;
        // 退款

        wx.showModal({
            title: '退款',
            content: '确认要进行退款',
            complete: (res) => {
                api.post({
                    url: 'order/backmoney',
                    data: {id:id,types:0},
                    success: data => {
                        console.log(data);
                        that.getoderbyid();
                    }
                })
            }
        })


     
    },
    backmoneys(ret){
        var id=this.data.id;
        var that=this;
        // 退款

        wx.showModal({
            title: '退款',
            content: '确认要进行退款',
            complete: (res) => {
                api.post({
                    url: 'order/backmoney',
                    data: {id:id,types:1},
                    success: data => {
                        console.log(data);
                        that.getoderbyid();
                    }
                })
            }
        })


     
    }

   

})